#include <amxmodx>
#include <fun>
#include <rpgx>

#define REGEN_INTERVAL 1.0

new upgrade_id;

public plugin_init()
	register_plugin("Regeneration RPGx Upgrade", "2.1", "roflmao456");

public RPGx_OnPluginReady(){
	upgrade_id = RPGx_MakeUpgrade("Regeneration", 5, 5, 10);
	set_task(REGEN_INTERVAL, "regeneration", 0, "", 0, "b");
	}

public regeneration(){
	new players[32], num, player, level, health, bonus;
	get_players(players, num, "a");
	
	for(new i;i<num;i++){
		player = players[i];
		level = RPGx_GetUpgradeLevel(player, upgrade_id);
		if(level){
			health = get_user_health(player);
			bonus = RPGx_GetSpawnHealth(player);
			set_user_health(player, bonus-health<=level?health+(bonus-health):health+level);
			}
		}
	}